<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<div id="app">
    <h1>异步请求</h1>
    <input type="button" value="发送get请求" @click="f1()">
    <input type="button" value="发送post请求" @click="f2()">
    <hr>
    <a href="/bmi.html">测试身体质量指数</a>
    <hr>
    <a href="/reg.html">注册</a>
    <a href="/login.html">登录</a>
</div>
</body>
<!--引入axios和vue框架文件-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v =  new Vue({
        el: '#app',
        data: function() {
            return {

            }
        },
        methods:{
            f1(){
                axios.get("/hel?name=zhangsan&age=18").then(function (response) {
                    alert(response.data)
                })
            },
            f2(){
                let phone = {title:"小米15",price:5999,num:100}
                //phone为js对象,response是回调后内容
                axios.post("/postAxios",phone).then(function (response) {
                    alert(response.data)
                })
            }
        }
    })
</script>
</html>